import java.util.*;
public class Main{
    public static void main(String[]args){
        Scanner scan=new Scanner(System.in);
        int n=scan.nextInt();
        scan.nextLine();
        String[] arr=new String[n];
        for(int i=0;i<n;i++){
            arr[i]=scan.nextLine();
        }
        if(isSortZiDian(arr)&&isSortLen(arr)){
            System.out.println("both");
        }else if(isSortZiDian(arr)){
            System.out.println("lexicographically");
        }else if(isSortLen(arr)){
            System.out.println("lengths");
        }else{
            System.out.println("none");
        }
    }
    public static boolean isSortZiDian(String[]arr){
        for(int i=0;i<arr.length-1;i++){
            if(arr[i].compareTo(arr[i+1])>0){
                return false;
            }
        }
        return true;
    }
    public static boolean isSortLen(String[]arr){
        for(int i=0;i<arr.length-1;i++){
            if(arr[i].length()>arr[i+1].length()){
                return false;
            }
        }
        return true;
    }
}
